package com.his.system.manager.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.his.system.manager.dto.LittleTeacherListDTO;
import com.his.system.manager.dto.LittleTeacherQueryDTO;
import com.his.system.manager.entity.LittleTeacherEntity;
import com.his.system.manager.mapper.LittleTeacherMapper;
import com.his.system.manager.service.ILittleTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * ILittleTeacherService实现类
 *
 * @Description
 * @Author Admin
 * @Date 2020-07-17 20:44:14
 */
@Service
public class LittleTeacherServiceImpl implements ILittleTeacherService {
    @Autowired
    private LittleTeacherMapper mapper;

    @Override
    public Integer addEntity(LittleTeacherEntity entity) {
        Integer res = mapper.insertSelective(entity);
        return res;
    }

    @Override
    public Integer updateEntity(LittleTeacherEntity entity) {
        Integer res = mapper.updateByPrimaryKey(entity);
        return res;
    }

    @Override
    public List<LittleTeacherEntity> selectByEntity(LittleTeacherEntity entity) {
        return mapper.selectByEntity(entity);
    }

    @Override
    public PageInfo<LittleTeacherListDTO> getListByPage(LittleTeacherQueryDTO queryDTO) {
        PageHelper.startPage(queryDTO.getPageNo(), queryDTO.getPageSize());
        List<LittleTeacherListDTO> list = mapper.getListByPage(queryDTO);
        if (list == null) {
            list = new ArrayList<>();
        }
        return new PageInfo<>(list);
    }
}